<?php

require_once '../include/common.inc.php';

if (!checkAdmin()) {
    header("LOCATION:index.php");
    exit;
}

$menu_index = 1;
$page_title = 'TABLA';
$guide_message = 'Product | Basic Information | Delete';

getMyParam('cid');

//ûϢ
$sql = "SELECT * FROM `pro_product` where id=$cid";
$query = $db->query($sql);
$pro_ary=$db->fetch_array($query);

$order=$pro_ary['orders'];
if($pro_ary['stock_status']==1) $pro_ary['stock_status']='Yes';
else $pro_ary['stock_status']='No';

if($pro_ary['is_best']==1) $pro_ary['is_best']='Yes';
else $pro_ary['is_best']='No';

if($pro_ary['is_featured']==1) $pro_ary['is_featured']='Yes';
else $pro_ary['is_featured']='No';

if($pro_ary['is_special']==1) $pro_ary['is_special']='Yes';
else $pro_ary['is_special']='No';

if($pro_ary['is_show']==1) $pro_ary['is_show']='Yes';
else $pro_ary['is_show']='No';

if($pro_ary['pic']!="") $pro_ary['pic']="<img src='../pictures/pro_product/pic/{$pro_ary['pic']}' width='100' height='100'>";
else $pro_ary['pic']='No Pictures';

if($pro_ary['video']!="") $pro_ary['video']="<a href='../pictures/pro_product/video/{$pro_ary['video']}'>{$pro_ary['video_name']}</a>";
else $pro_ary['video']='No Video';

//type
$sql = "SELECT `name` FROM `pro_type` where id in(select type_id  from pro_product_type  where product_id=$cid)";
$query = $db->query($sql);
while($rs = $db->fetch_array($query)) {

	$type_show.=$rs['name'];
	$type_show.=" / ";
}
$type_show=substr($type_show,0,strlen($type_show)-2);


//category
$sql = "SELECT `name` FROM `pro_category` where id in(select category_id  from pro_product_category  where product_id=$cid)";
$query = $db->query($sql);
while($rs = $db->fetch_array($query)) {

	$category_show.=$rs['name'];
	$category_show.=" / ";
}
$category_show=substr($category_show,0,strlen($category_show)-2);

//Publisher
$sql = "SELECT `name` FROM `pro_publisher` where id=(select publiser_id from pro_product where id=$cid)";
$query = $db->query($sql);
while($rs = $db->fetch_array($query)) {
	$publisher_show.=$rs['name'];
}

//Author
$sql = "SELECT `name` FROM `pro_author` where id=(select author_id from pro_product where id=$cid)";
$query = $db->query($sql);
while($rs = $db->fetch_array($query)) {
	$author_show.=$rs['name'];
}


//Supplier
$sql = "SELECT `name` FROM `pro_supplier` where id=(select supplier_id from pro_product where id=$cid)";
$query = $db->query($sql);
while($rs = $db->fetch_array($query)) {
	$supplier_show.=$rs['name'];
}


include_once('menu_list.php');
require_once PrintEot('a_header');
require_once PrintEot('a_p_product_del');
require_once PrintEot('a_footer');

?>